#pragma once

#include <QtWidgets/QWidget>
#include "ui_QrencodeTools.h"
#include "qrencode.h" 
#include <QPainter>
#include <QDebug>
#include <QFileDialog>
#include <QButtonGroup>
#include "GBK.h"

class QrencodeTools : public QWidget
{
    Q_OBJECT

public:
/**
 * @brief Default QR size setting
 *
 */
#define DEFAULT_QR_SHOW_LABEL_SIZE		250
#define DEFAULT_QR_SAVE_IMAGE_SIZE		640

/**
 * @brief QR background setting
 *
 */
typedef enum {
	QR_BKGD_ID_WHITE = 0x01,
	QR_BKGD_ID_TRANSPARENT = 0x02,
}QR_BKGD_ID_E;

public:
    QrencodeTools(QWidget *parent = Q_NULLPTR);
	~QrencodeTools();
	void setString(QString str);
	bool saveImage(QString name, int size);
	void draw(QPainter &painter, int width, int height);
	void drawQRImage();

protected:
	bool eventFilter(QObject *watched, QEvent *event);

private slots:
	void ShowBtnClicked();
	void SaveBtnClicked();

private:
    Ui::QrencodeToolsClass ui;
	QButtonGroup* qrBtnGroup;
	QString string;
	QRcode *qr;
};
